using Game.Core;
using Game.Main.Model;
using Game.Main.View;
using Game.Manager;
using UnityEngine;

namespace Game.Component
{
	public class CameraItem : BaseItem
	{
		private Transform cameraTrans;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
			cameraTrans = model.Find("Camera");
			cameraTrans.gameObject.layer = 15;
		}

		public override void QuicklyTouch(TouchEventData touchEventData)
		{
			base.QuicklyTouch(touchEventData);
			RaycastHit2D[] array = Physics2D.RaycastAll(touchEventData.curPos, Vector2.zero, 15f, 32768);
			for (int i = 0; i < array.Length; i++)
			{
				if (!(array[i].collider != null) || !(array[i].collider.transform == cameraTrans))
				{
					continue;
				}
				if (base.itemData.createIds != null && archiveData.createIndexs.Count < base.itemData.createAmount)
				{
					BaseItem baseItem = Singleton<Scene>.Instance.CreateItem(base.itemData.createIds[0], cameraTrans.position, 0);
					if (baseItem != null)
					{
						AddCreateItem(baseItem);
						baseItem.DropDown(base.transform.position);
						Singleton<AudioManager>.Instance.PlaySound("sound_take_photo");
					}
				}
				break;
			}
		}
	}
}
